package com.wn.sddfp.trade.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wn.sddfp.common.model.dto.bank.BankCardAddDTO;
import com.wn.sddfp.common.model.dto.bank.BankCardRequestDto;
import com.wn.sddfp.common.model.dto.borrow.BorrowRecordDTO;
import com.wn.sddfp.common.model.dto.borrow.BorrowRecordQuery;
import com.wn.sddfp.common.model.dto.borrow.BorrowRecordVo;
import com.wn.sddfp.common.model.dto.borrow.Pages;
import com.wn.sddfp.common.model.result.Result;
import com.wn.sddfp.trade.entity.BorrowRecord;
import com.wn.sddfp.trade.service.IBorrowRecordService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author yellow Docter
 * @date 2023 -07-31
 * @desc
 */
@RestController
public class TradeController {

    @Autowired
    private IBorrowRecordService borrowRecordService;

    /**
     * 借款的接口
     */

    @ApiOperation("借款申请")
    @PostMapping("/trade/borrow/add")
    public Result addBorrowRecord(@RequestBody BorrowRecordDTO borrowRecordDTO){
        borrowRecordService.addBorrowRecord(borrowRecordDTO);
        return Result.ok();
    }

    @ApiOperation("借款记录查询")
    @PostMapping("/trade/borrow/query")
    public Result<Pages<BorrowRecordVo>> queryBorrowRecord(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "2") Integer pageSize,
            @RequestBody BorrowRecordQuery borrowRecordQuery) {
        Pages<BorrowRecordVo> pages =
                borrowRecordService.queryBorrowRecord(pageNum,pageSize,borrowRecordQuery);
        return Result.ok(pages);
    }

    /**
     *
     * @param approveStatus       借款审核状态
     * @param borrowRecordId      借款记录id
     * @return
     */
    @ApiOperation("借款审核接口,同步借款数据")
    @PutMapping("/trade/borrow/status")
    public Result verifyStatus(Integer approveStatus,Long borrowRecordId){
        String result = borrowRecordService.verifyStatus(approveStatus,borrowRecordId);
        return Result.ok(result);
    }

}
